import React, { useEffect,useRef } from 'react'
import { useDispatch, useSelector } from "react-redux"
import {action1,action2,UpdateUserAction} from "@/redux/actions"
import useRequest from "@/hooks/useRequest"


export default function Salary() {
  const {CountRD,UserRD} = useSelector(state => {
    return state
  })
  const h2Ref = useRef(null)
  const dispatch = useDispatch()
  const {getUsers,deleteUser} = useRequest()

  const decrement = () => {
    dispatch(action2)
  }
  const increment = () => {
    dispatch(action1)
  }

  const changeName = ()=>{
    // dispatch(UpdateUserAction("周军"))
    getUsers()
  }


  return (
    <div>
      <h2>Salary</h2>
      <p ref={h2Ref}>{CountRD.count}</p>
      <button onClick={decrement}>-</button>
      <button onClick={increment}>+</button>
      <p>{UserRD.user.length}</p>
      <button onClick={changeName}>修改名字</button>
    </div>
  )
}
